// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: MIT

package metrics

import (
	"time"

	"github.com/prometheus/client_golang/prometheus"
)

type TimeCollector struct {
	desc *prometheus.Desc
}

func NewTimeCollector() *TimeCollector {
	return &TimeCollector{
		desc: prometheus.NewDesc(
			prometheus.BuildFQName("time", "system", "seconds"),
			"Current System time.",
			nil,
			nil,
		),
	}
}

func (c *TimeCollector) Update(ch chan<- prometheus.Metric) error {
	currentTime := float64(time.Now().Unix())
	ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, currentTime)
	return nil
}
